﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace POVRay {
    public class Rainbow {
        public Vector3? Direction { get; set; }
        public float? Angle { get; set; }
        public float? Width { get; set; }
        public float? Distance { get; set; }
        public ColorMap ColorMap { get; set; }
        public float? Jitter { get; set; }
        public Vector3? Up { get; set; }
        public float? ArcAngle { get; set; }
        public float? FalloffAngle { get; set; }

        public Rainbow(Vector3 direction, float angle, float width, float distance, ColorMap colorMap) {
            Direction = direction;
            Angle = angle;
            Width = width;
            Distance = distance;
            ColorMap = colorMap;
        }

        public string ToString(int level) {
            StringBuilder sb = new StringBuilder();
            sb.Append("rainbow { ");

            if (Direction.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "direction " + Direction.Value.ToString() + " ");
            }
            if (Angle.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "angle " + Angle.Value.POVRayString() + " ");
            }
            if (Width.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "width " + Width.Value.POVRayString() + " ");
            }
            if (Distance.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "distance " + Distance.Value.POVRayString() + " ");
            }
            if (ColorMap != null) {
                sb.Append(Scene.Indentation(level + 1) + ColorMap.ToString(level + 1) + " ");
            }
            if (Jitter.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "jitter " + Jitter.Value.POVRayString() + " ");
            }
            if (Up.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "up " + Up.Value.ToString() + " ");
            }
            if (ArcAngle.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "arc_angle " + ArcAngle.Value.POVRayString() + " ");
            }
            if (FalloffAngle.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "falloff_angle " + FalloffAngle.Value.POVRayString() + " ");
            }
            
            sb.Append(Scene.Indentation(level) + "}");
            return sb.ToString();
        }
    }
}
